package com.hms.dao.impl;

import org.springframework.stereotype.Component;

import com.hms.dao.IRoleDao;
import com.hms.entity.Role;

@Component
public class RoleDao extends BaseDao<Role, String> implements IRoleDao {

	@Override
	public void delete(String id) {
		Role entity = this.load(id);
		this.delete(entity);
	}

	@Override
	public void delete(Role entity) {
		if (entity.getIsSystem()) {
			return;
		}
		super.delete(entity);
	}

	@Override
	public void delete(String[] ids) {
		for (String id : ids) {
			this.delete(id);
		}
	}

	@Override
	public String save(Role entity) {
		entity.setIsSystem(false);
		return super.save(entity);
	}

}
